package cn.imokay.queue;

import java.util.concurrent.ArrayBlockingQueue;

public class BlockingQueueDemo {
    public static void main(String[] args) throws InterruptedException {
        ArrayBlockingQueue<String> strings = new ArrayBlockingQueue<>(10);

        //满空跑错
        System.out.println(strings.add(""));
        System.out.println(strings.remove());

        //满空返回fasle，带时间参数时，满空时会阻塞指定的时间长度
        System.out.println(strings.offer(""));
        System.out.println(strings.poll());

        //满空阻塞
        strings.put("");
        strings.take();
    }
}
